package com.iuv.imdemo;

import com.iuv.config.ImSetting;
import com.iuv.imdemo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class ImdemoApplication extends SpringBootServletInitializer {
    @Value("${IM.sdkAppid}")
    private Long sdkAppid;
    @Value("${IM.Key}")
    private String key;
    @Value("${IM.identifier}")
    private String identifier;
    @Autowired
    private UserInfoService userInfoService;

    public static void main(String[] args) {
        SpringApplication.run(ImdemoApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ImdemoApplication.class);
    }

    @PostConstruct
    public void init() {
        ImSetting.SDK_APP_ID = sdkAppid;
        ImSetting.KEY = key;
        ImSetting.IDENTIFIER = identifier;
        userInfoService.importUserInfo();
    }

}
